home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
hugearr.zip
/
HUGEARR.TXT
< prev
next >
Wrap
Text File
|
1992-04-02
|
18KB
|
554 lines
HUGEARR.DLL
Huge array support for Microsoft Visual Basic
from Microsoft Product Support Services 6/4/91
with additions by various authors
The following information applies to Microsoft Visual Basic
programming system version 1.0 for Microsoft Windows, and to Microsoft
Windows 3.0 Software Development Kit (SDK).
HUGEARR.DLL is a dynamic-link library (DLL) which contains functions
for creation, maintenance, and deletion of arrays larger than 64K from
Microsoft Visual Basic version 1.00 for Windows. This DLL also gives
the ability to create arrays with more than 32,767 (32K) elements per
dimension, and to redimension arrays while preserving the data inside
of the arrays.
To use the functions in HUGEARR.DLL, simply copy the declarations
contained in HUGEARR.VBG into your global module in Visual Basic, copy
the declarations in HUGEARR.VBM into any module, and copy HUGEARR.DLL
to your Windows directory. The functions can then be used like any other
Windows DLL function.
HUGEARR.DLL allocates memory using the Windows API function
GlobalAlloc. This means that the largest array that can be allocated
is 1 MB in standard mode, and 64 MB in 386 enhanced mode for Windows.
The following routines are contained in HUGEARR.DLL. For a complete
description of the parameters and/or return values of these routines,
see Visual Basic's Declare statement for the routine in question in
the file HUGEARR.VBM.
HUGEARR.DLL Language Reference:
------------------------------
-------------------------------------------------------------------------
VBHugeDim:
Action: Dimensions an array and returns a handle to that array.
Syntax: VBHugeDim(recsize%, limit&)
Argument Description
-------- -----------
recsize% The size of each element in the array. (i.e. an integer
would be 2, a double would be 8.) You can use the Len()
function to determine the size of any data type if you are
unsure.
limit& The upper bound of the array. The lower bound of all arrays
is 0, so for example: 'VBHugeDim(2, 10)' would create an
integer array of elements 0 through 10.
Remarks:
-------
You should not try to create a huge array of variable-length strings, or of
a user-defined type that contains variable-length strings. Visual Basic's
string handling routines would not know of the existence of any string that
was controlled by HUGEARR.DLL, and a UAE ("Unrecoverable Application Error")
would probably result. Fixed-length strings are okay though.
VBHugeDim returns a handle to the array that was created, and that handle is
used when referring to that array with other commands. If an error
occurred (such as out of memory), it will return a negative number. Error
codes are detailed below under the section entitled 'Error Codes'.
Example:
-------
Sub Command1_Click()
Dim hArray as integer
Dim variable as SomeUserDefinedType
hArray = VBHugeDim(Len(variable), 10)
If hArray < 0 Then
print "Error dimensioning array:"; hArray
Stop
End If
.
.
.
i% = VBHugeErase(hArray)
End Sub
-------------------------------------------------------------------------
VBHugeErase:
Action: Erases an array that was previously dimensioned using VBHugeDim.
Syntax: VBHugeErase(hArray%)
Argument Description
-------- -----------
hArray% The handle to the array. (The same handle that was returned
by VBHugeDim.)
Remarks:
--------
You should be sure to VBHugeErase all arrays that were VBHugeDim'd. Failing to
do so would cause the memory used by the array to not be freed up until the
application quits. If many arrays are dimensioned but never erased memory
would keep being allocated without being freed, eventually degrading system
performance.
Example: Refer to the example for VBHugeDim.
-------------------------------------------------------------------------
VBHugeRedim:
Action: Redimensions an array created with VBHugeDim to a different size.
Syntax: VBHugeRedim(hArray%, limit&)
Argument Description
-------- -----------
hArray% The handle to the array to redimension.
limit& The new upper bound of the array.
Remarks:
--------
VBHugeRedim, unlike Visual Basic's ReDim, preserves all the data in the
array. If you want to erase the contents of the array, you should erase it
and the dimension it again.
If the size of the array would go over 64K when it is redimensioned, it is
subject to the same size restrictions detailed in the discussion of
VBHugeDim.
You cannot change the size of the elements in the array, only the number of
elements.
Example:
--------
Sub Command1_Click()
.
.
i% = VBHugeRedim(hArray, 50)
if i% < 0 then
print "error redimensioning array:"; hArray
stop
End If
e% = VBHugeErase(hArray)
End Sub
-------------------------------------------------------------------------
VBHugeGet, VBHugeSet:
Action: Gets or sets the contents of an array element.
Syntax: VBHugeGet(hArray%, el&, variable)
VBHugeSet(hArray%, el&, variable)
Argument Description
-------- -----------
hArray% The handle to the array.
el& The element of the array to set or get the data from.
variable The variable to get into, or to set the array from.
Remarks:
--------
It is extremely important that the type for the variable passed to
VBHugeGet or VBHugeSet matches that type of the variable used in the
VBHugeDim statement, if the types are of different lengths, you will mostly
likely get a UAE or overwrite other data. If you want to be sure that the
types match you can use the Alias keyword when you declare the function to
introduce type checking. Refer to the section below entitled 'Aliasing'
for more information on aliases.
Example:
--------
Sub Command2_Click()
.
.
.
hArray = VBHugeDim(len(i%), 10)
If hArray < 0 Then Stop
e% = VBHugeSet(hArray, 1, 54%) ' puts 54 into element #1
If e% < 0 Then Stop ' check error code
e% = VBHugeGet(hArray, 1, i%) ' get element #1 into i%
Print i%
e% = VBHugeErase(hArray)
End Sub
-------------------------------------------------------------------------
VBHugeGetNum, VBHugeSetNum:
Action: Gets or sets the contents of multiple array elements.
Syntax: VBHugeGetNum(hArray%, el&, nelem%, variable)
VBHugeSetNum(hArray%, el&, nelem%, variable)
Argument Description
-------- -----------
hArray% The handle to the array.
el& The first element of the array to set or get the data from.
nelem% The number of elements to be set or fetched.
variable The variable to get into, or to set the array from.
Remarks:
--------
See the Remarks for VBHugeGet, VBHugeSet.
Example:
--------
Sub Command2_Click()
.
.
Dim VBArray() as Double
ReDim VBArray(1 to 1000)
' Assign something to the elements in VBArray.
.
.
hArray = VBHugeDim(len(i#), 1000)
If hArray < 0 Then Stop
' Copy 1000 elements from VB array VBArray(1...1000) to huge array.
e% = VBHugeSetNum(hArray, 1, 1000, VBArray(1))
' check error code
If e% < 0 Then Stop
' Copy 1000 elements from huge array to VB array VBArray(1...1000).
e% = VBHugeGetNum(hArray, 1, 1000, VBArray(1))
e% = VBHugeErase(hArray)
End Sub
------------------------------------------------------------------------
VBHugeSave:
Action: Saves the specified number of elements of a huge array to the
named file.
Syntax: VBHugeSave(hArray%, NEl&, RecLen%, Fn$)
Remarks:
-------
The number of elements to save as well as the size of each element,
together with the full filen